package com.santu.edu.supporter.biz.order.wm.pojo.dto;

import com.santu.edu.supporter.biz.order.common.pojo.enums.OrderStatusEnum;
import com.santu.edu.supporter.biz.order.wm.pojo.enums.WmTypeEnum;
import com.santu.edu.supporter.biz.order.wm.pojo.params.WmOrderAddParam;
import com.santu.edu.supporter.biz.order.wm.pojo.params.WmOrderUpdateParam;
import com.santu.edu.supporter.biz.order.wm.pojo.po.WmOrderPO;
import lombok.Data;
import lombok.experimental.Accessors;

/**
 * @author luoyaoqi
 * @createTime 2024/2/22
 * @description
 */
@Data
@Accessors(chain = true)
public class WmOrderDTO {


    /**
     * 学校id
     */
    private String schoolId;

    /**
     * 订单号
     */
    private String orderId;

    /**
     * 用户id(发起人)
     */
    private String userId;

    /**
     * 跑路费
     */
    private Long money;

    /**
     * 楼道id
     */
    private String buildingsId;

    /**
     * 购买的商品信息
     */
    private String goodInfo;

    /**
     * 商品图片地址
     */
    private String imageUrl;

    /**
     * 打赏金额
     */
    private Long tipping;

    /**
     * 备注信息
     */
    private String remarkInfo;

    /**
     * 送货地址id
     */
    private String addressId;

    /**
     * 订单状态[0:待认领1:进行中2:已完成]
     */
    private OrderStatusEnum orderType;

    /**
     * 外卖的状态[0:外卖未送到1:外卖已送到,2:已取货]
     */
    private WmTypeEnum wmType;

    /**
     * 送达照片
     */
    private String sendGoodImage;


    public static WmOrderDTO createItem(WmOrderAddParam addParam, String orderId) {
        return new WmOrderDTO()
                .setSchoolId(addParam.getSchoolId())
                .setOrderId(orderId)
                .setUserId(addParam.getUserId())
                .setMoney(addParam.getMoney())
                .setBuildingsId(addParam.getBuildingsId())
                .setGoodInfo(addParam.getGoodInfo())
                .setImageUrl(addParam.getImageUrl())
                .setTipping(addParam.getTipping())
                .setRemarkInfo(addParam.getRemarkInfo())
                .setAddressId(addParam.getAddressId())
                .setOrderType(OrderStatusEnum.IN_PROGRESS)
                .setWmType(WmTypeEnum.convert(addParam.getWmType()));
    }


    public static WmOrderDTO createItem(WmOrderUpdateParam updateParam) {
        return new WmOrderDTO()
                .setOrderId(updateParam.getOrderId())
                .setAddressId(updateParam.getAddressId());
    }

    public static WmOrderDTO createItem(WmOrderPO item) {
        return new WmOrderDTO()
                .setSchoolId(item.getSchoolId())
                .setOrderId(item.getOrderId())
                .setUserId(item.getUserId())
                .setMoney(item.getMoney())
                .setBuildingsId(item.getBuildingsId())
                .setGoodInfo(item.getGoodInfo())
                .setImageUrl(item.getImageUrl())
                .setTipping(item.getTipping())
                .setRemarkInfo(item.getRemarkInfo())
                .setAddressId(item.getAddressId())
                .setOrderType(OrderStatusEnum.convert(item.getOrderType()))
                .setWmType(WmTypeEnum.convert(item.getWmType()))
                .setSendGoodImage(item.getSendGoodImage());
    }
}
